package com.example.zhanghehe.myapplication.opengl3

import android.app.ActivityManager
import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log

class OpenGL3Activity :AppCompatActivity(){


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if(detectOpenGLES30()){
            Log.d(TAG,"OpenGL ES 3.0 not supported on device.  Existing....")
            setContentView(OpenGl3SurfaceView(this@OpenGL3Activity))
        }else{
            Log.d(TAG,"OpenGL ES 3.0 not supported on device.  Existing....")
            finish()
        }
    }

    private fun detectOpenGLES30(): Boolean {
        val am=getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val info=am.deviceConfigurationInfo
        return info.reqGlEsVersion>=0x30000
    }

    companion object {
        private val TAG=OpenGL3Activity::class.java.simpleName
    }
}
